#!/usr/bin/env node

const path = require('path')
const { spawn } = require('child_process')

// 设置环境变量
process.env.NODE_ENV = 'development'
process.env.UNI_PLATFORM = 'mp-weixin'
process.env.UNI_CLI_CONTEXT = path.resolve(__dirname, '..')
process.env.UNI_INPUT_DIR = path.resolve(__dirname, '../src')
process.env.UNI_OUTPUT_DIR = path.resolve(__dirname, '../dist/dev/mp-weixin')

// 启动 vue-cli-service
const vueCli = path.resolve(__dirname, '../node_modules/.bin/vue-cli-service' + (process.platform === 'win32' ? '.cmd' : ''))
const child = spawn(vueCli, ['uni-build', '--watch'], {
  stdio: 'inherit',
  shell: true,
  env: process.env
})

child.on('exit', (code) => {
  process.exit(code)
})

